﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Manage/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Areas.Manage.Models.Issue.SearchIssue>" %>

<%@ Import Namespace="Code.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	期号管理
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<fieldset>
    <legend>期号管理</legend>
<div align="center">
<% Html.BeginForm(); %>
<%=Html.HiddenFor(p=>p.PageInfo.PageCount) %>
    <table class="table" width="100%">
        <tr>
            <td align="right">彩种:</td><td align="left"><%=Html.DropDownList("model.Search.LotteryID", Model.LotteryList, "选择彩种", new {@class="lottery" })%></td>
            <td align="right">状态:</td><td align="left">
                <select id="State" name="Model.Search.State">
                    <option value>状态</option>
                    <option value='<%=(short)IssueState.Opened %>' <%=Model.Search.State==(short)IssueState.Opened?"selected='selected'":"" %>><%=IssueState.Opened.GetName() %></option>
                    <option value='<%=(short)IssueState.Normal%>' <%=Model.Search.State==(short)IssueState.Normal?"selected='selected'":"" %>><%=IssueState.Normal.GetName() %></option>
                </select>
            </td>
        </tr>
        <tr>
            <td align="right">开始时间:</td><td align="left"><%=Html.TextBox("Model.Search.StartTime", string.Format("{0:yyyy-MM-dd}", Model.Search.StartTime), new { @class = "text100 stime", onClick = "WdatePicker()" })%></td>
            <td align="right">结束时间:</td><td align="left"><%=Html.TextBox("Model.Search.EndTime", string.Format("{0:yyyy-MM-dd}", Model.Search.EndTime), new { @class = "text100 etime", onClick = "WdatePicker()" })%></td>
        </tr>
        <tr>
            <td align="right">期号:</td><td align="left"><%=Html.TextBox("Model.Search.FomartNumber",Model.Search.FomartNumber, new { @class = "text100" }) %></td>
            <td colspan='2'>
                <input type="submit" name="Search" value="查找" /> 
                <input type="submit" name="Add" value="添加期号" onclick="return AddIssue()" />
                <input type="submit" name="Delete" value="删除期号" onclick="return DeleteIssue()" />
            </td>
        </tr>
    </table>
    <table class="table" width="100%">
         <tr>
            <th>期号</th><th>彩种</th><th>开始时间</th><th>结束时间</th><th>开奖号码</th><th>状态</th><th>操作<input type="checkbox" onclick='IssueList_ckb_Click(this)' /></th>
         </tr>
         <% 
             foreach (var issue in Model.IssueList)
	        { 
		    %>
                <tr>
                    <td><%=issue.FormatIssueName %></td>
                    <td><%=issue.LotteryName %></td>
                    <td><%=issue.StartTime %></td>
                    <td><%=issue.EndTime %></td>
                    <td><%=issue.OpenCode %></td>
                    <td><%=((IssueState)issue.State).GetName() %></td>
                    <td>
                        <% if (issue.ChaseTask_Detail.Count == 0 && issue.Scheme.Count == 0){ %>
                        <input type="checkbox" name="cbkIssueID" value='<%=issue.ID %>' />
                        <%} %>
                    </td>
                </tr>    
            <%
	        }if(Model.IssueList!=null&&Model.IssueList.Count>0){ %>
                <tr><td colspan='7' align="right"><input type="submit" value="删除选中项" name="DeleteChose"  onclick="return IssueList_btn_Click()" /></td></tr>
                <tr><td colspan='7'><%=Html.Pager(Model.PageInfo.CurrPage, Model.PageInfo.PageCount, Model.PageInfo.SunCount, "search.PageInfo.CurrPage", Url.Route(new { search = new { Model.Search }, retunUrl = Request["returnUrl"] }), "search.PageInfo.PageCount")%></td></tr>
            <%} %>
    </table>
 <% Html.EndForm(); %>
</div>
</fieldset>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
<script type="text/javascript">
    function IssueList_ckb_Click(ckb) {
        var ckbs = document.getElementsByName('cbkIssueID');
        for (var i = 0; i < ckbs.length; i++) {
            ckbs[i].checked = ckb.checked;
        }
    }
    function IssueList_btn_Click() {
        var ckbs = document.getElementsByName('cbkIssueID');
        for (var i = 0; i < ckbs.length; i++) {
            if (ckbs[i].checked)
                return true;
        }
        alert('您没有选中任何项!');
        return false;
    }
    function DeleteIssue() {
        var lottery = $('.lottery').val();
        var stime = $('.stime').val();
        var etime = $('.etime').val();
        if (etime == '') {
            alert('请选择您要删除的期号的结束时间');
            return false;
        }
        var str = '您确定要删除';
        if (lottery == '') {
            str += ' 所有彩种 '
        }
        else {
            str += '当前彩种';
        }
        if (stime!= '') {
            str += '从' + stime + '到' + etime + '之间的期号吗？';
        } else {
            str += etime + '之前的期号吗？';
        }
        return confirm(str);
    }
    function AddIssue() {
        var lottery = $('.lottery').val();
        var stime = $('.stime').val();
        var etime = $('.etime').val();
        if (lottery == '') {
            alert('请选择您要添加期号的彩种');
            return false;
        }
        if (stime == '') {
            alert('请输入您要添加期号的开始时间');
            return false;
        }
        if (etime == '') {
            alert('请输入您要添加期号的结束时间');
            return false;
        }
        return confirm('请确定要添加期号?');
    }
</script>
</asp:Content>
